<template>
  <div class="wholeshelfContent">
    <div class="wholeshelfTitle">
      <div class="customerTitle">海川医药整件上架{{ systemTime }}日报</div>
      <el-date-picker
        v-model="dateRange"
        style="width: 240px"
        value-format="yyyy-MM-dd"
        type="date"
      ></el-date-picker>
      <el-button type="success" @click="saveshelfdaily">保存</el-button>
    </div>
    <div class="wholeshelfTable">
      <div class="customtr1">
        <div class="customText">客户/类别</div>
        <div class="delivery">
          <div class="deliveryTop">上架完成</div>
          <div class="deliveryBottom">
            <span>上架条目</span>
            <span>上架件数</span>
          </div>
        </div>
      </div>
      <div class="customtr2">
        <div class="customText wyLayout">陕西海通</div>
        <div class="delivery">
          <div class="deliveryTop">
            <el-input
              @input="calculatewcsjtmTotal"
              v-model="form.htSjtm"
              size="medium"
            />
          </div>
        </div>
        <!-- <div class="customText">
        <el-input
          @input="calculatebhxsTotal"
          v-model="form.htOutBhxs"
          size="medium"
        />
      </div> -->
        <div class="delivery">
          <div class="deliveryTop noborder">
            <el-input
              v-model="form.htSjjs"
              @input="calculatewcsjjsTotal"
              size="medium"
            />
          </div>
        </div>
      </div>
      <div class="customtr2">
        <div class="customText wyLayout">陕西伟业</div>
        <div class="delivery">
          <div class="deliveryTop">
            <el-input
              @input="calculatewcsjtmTotal"
              v-model="form.wySjtm"
              size="medium"
            />
          </div>
        </div>
        <div class="delivery">
          <div class="deliveryTop noborder">
            <el-input
              @input="calculatewcsjjsTotal"
              v-model="form.wySjjs"
              size="medium"
            />
          </div>
        </div>
      </div>
      <div class="customtr3">
        <div class="customText wyLayout">大洋</div>
        <div class="customText">
          <el-input
            @input="calculatewcsjtmTotal"
            v-model="form.dySjtm"
            size="medium"
          />
        </div>
        <div class="completeText">
          <el-input
            @input="calculatewcsjjsTotal"
            v-model="form.dySjjs"
            size="medium"
          />
        </div>
      </div>
      <div class="customtr3">
        <div class="customText wyLayout">其他货主</div>
        <div class="customText">
          <el-input
            @input="calculatewcsjtmTotal"
            v-model="form.qtSjtm"
            size="medium"
          />
        </div>
        <div class="completeText">
          <el-input
            @input="calculatewcsjjsTotal"
            v-model="form.qtSjjs"
            size="medium"
          />
        </div>
      </div>
      <div class="customtr4">
        <div class="customText wyLayout">合计</div>
        <div class="customText">
          <el-input disabled v-model="wcsjtmTotal" size="medium" />
        </div>
        <div class="completeText">
          <el-input disabled v-model="wcsjjsTotal" size="medium" />
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { dailyaddshelf, dailylistshelf } from "@/api/system/daily";
export default {
  data() {
    return {
      dateRange: new Date().toISOString().split("T")[0],
      // 陕西海通零货条目数
      ids: null,
      systemTime: "",
      wcsjtmTotal: undefined,
      wcsjjsTotal: undefined,
      // 伟业
      form: {
        // rbSj: new Date().toISOString().split("T")[0],
        htSjtm: null,
        htSjjs: null,
        wySjtm: null,
        wySjjs: null,
        dySjtm: null,
        dySjjs: null,
        qtSjtm: null,
        qtSjjs: null,
      },
    };
  },
  mounted() {
    // 创建一个 Date 对象
    const currentDate = new Date();
    // 获取当前年份
    const year = currentDate.getFullYear();
    // 获取当前月份（注意：月份是从 0 开始计数的，所以需要加 1）
    const month = currentDate.getMonth() + 1;
    // 获取当前日期
    const day = currentDate.getDate();
    // 打印年月日
    this.systemTime = `${year}年${month}月${day}日`;
    this.getshelfList();
  },
  beforeDestroy() {},
  methods: {
    // 保存
    saveshelfdaily() {
      this.$set(this.form, "rbSj", this.dateRange);
      console.log(this.form);
      dailyaddshelf(this.form).then((res) => {
        this.$modal.msgSuccess("新增成功");
        this.getshelfList();
      });
    },
    getshelfList() {
      dailylistshelf().then((res) => {
        if (res.data) {
          this.form = res.data;
          this.wcsjtmTotal =
            Number(this.form.htSjtm) +
            Number(this.form.wySjtm) +
            Number(this.form.dySjtm) +
            Number(this.form.qtSjtm);
          this.wcsjjsTotal =
            Number(this.form.htSjjs) +
            Number(this.form.wySjjs) +
            Number(this.form.dySjjs) +
            Number(this.form.qtSjjs);
        }
      });
    },
    calculatewcsjtmTotal() {
      this.wcsjtmTotal =
        Number(this.form.htSjtm) +
        Number(this.form.wySjtm) +
        Number(this.form.dySjtm) +
        Number(this.form.qtSjtm);
    },
    calculatewcsjjsTotal() {
      this.wcsjjsTotal =
        Number(this.form.htSjjs) +
        Number(this.form.wySjjs) +
        Number(this.form.dySjjs) +
        Number(this.form.qtSjjs);
    },
  },
};
</script>

<style lang="scss" scoped>
.wholeshelfContent {
  width: 100%;
  height: 100%;
  ::v-deep .el-table__body-wrapper {
    border: 1px solid #181616;
  }
  .el-table--group::after,
  .el-table--border::after {
    background-color: #181616;
  }
  ::v-deep .el-table--enable-row-hover .el-table__body tr:hover > td {
    background-color: transparent;
  }

  ::v-deep .el-date-editor.el-input,
  .el-date-editor.el-input__inner {
    width: 100%;
  }
  // ::v-deep .el-input--prefix .el-input__inner {
  //   // border: none;
  // }
  ::v-deep .el-table tr {
    height: 70px;
  }

  .wholeshelfTitle {
    display: flex;
    align-items: center;
    .customerTitle {
      width: 100%;
      font-size: 24px;
      font-weight: 700;
      margin: 30px 0 40px 0;
    }
    ::v-deep .el-button--success {
      height: 36px;
      margin-left: 20px;
    }
  }
  .wholeshelfTable {
    width: 100%;
    ::v-deep .el-input__inner {
      height: 65px;
      line-height: 65px;
      border: none;
      text-align: center;
      color: #000000;
      width: 100%;
    }
  }
  .customtr1 {
    width: 100%;
    height: 140px;
    border: 1px solid #e7dfdf;
    background: #05a5ff;
    display: flex;
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
    justify-content: space-around;
    .customText {
      width: 33.3%;
      height: 140px;
      line-height: 140px;
      text-align: center;
      border-right: 1px solid #e7dfdf;
    }
    .completeText {
      width: 33.3%;
      height: 140px;
      line-height: 140px;
      text-align: center;
    }
    .delivery {
      width: 66.7%;
      display: flex;
      flex-direction: column;
      .deliveryTop {
        height: 50%;
        line-height: 70px;
        border-right: 1px solid #e7dfdf;
      }
      .deliveryBottom {
        height: 50%;
        display: flex;
        justify-content: space-around;
        border-top: 1px solid #e7dfdf;
        span {
          width: 50%;
          height: 100%;
          line-height: 70px;
          text-align: center;
          border-right: 1px solid #e7dfdf;
        }
      }
    }
  }
  .customtr2 {
    width: 100%;
    height: 70px;
    border-bottom: 1px solid #181616;
    border-left: 1px solid #181616;
    border-right: 1px solid #181616;
    // background: #00d9ff;
    display: flex;
    justify-content: space-around;
    .customText {
      width: 33.3%;
      height: 70px;
      line-height: 70px;
      text-align: center;
      border-right: 1px solid #181616;
    }
    .wyLayout {
      font-weight: 700;
    }
    .delivery {
      width: 33.3%;
      display: flex;
      flex-direction: column;
      //   border-right: 1px solid #181616;
      .deliveryTop {
        height: 100%;
        line-height: 70px;
        border-right: 1px solid #181616;
      }
      .noborder {
        border-right: none !important;
      }
      // .deliveryBottom {
      //   height: 50%;
      //   display: flex;
      //   line-height: 70px;
      //   justify-content: space-around;
      //   border-top: 1px solid #181616;
      //   border-right: 1px solid #181616;
      // }
    }
  }
  .customtr3 {
    width: 100%;
    height: 70px;
    border-bottom: 1px solid #181616;
    border-left: 1px solid #181616;
    border-right: 1px solid #181616;
    // background: #00d9ff;
    display: flex;
    justify-content: space-around;
    .customText {
      width: 33.3%;
      height: 70px;
      line-height: 70px;
      text-align: center;
      border-right: 1px solid #181616;
    }
    .totalText {
      width: 20%;
    }
    .wyLayout {
      font-weight: 700;
    }
    .completeText {
      width: 33.3%;
      height: 70px;
      line-height: 70px;
      text-align: center;
    }
  }
  .customtr4 {
    width: 100%;
    height: 70px;
    border-bottom: 1px solid #181616;
    border-left: 1px solid #181616;
    border-right: 1px solid #181616;
    background: #75d561;
    display: flex;
    justify-content: space-around;
    ::v-deep .el-input.is-disabled .el-input__inner {
      background: #75d561;
      font-weight: 700;
      color: #ff4800;
      font-size: 18px;
    }
    .customText {
      width: 33.3%;
      height: 70px;
      line-height: 70px;
      text-align: center;
      border-right: 1px solid #181616;
    }
    .bhxsbg {
      background: #f5f7fa;
      border-bottom: 1px solid #181616;
    }
    .wyLayout {
      font-weight: 700;
    }
    .completeText {
      background: #75d561;
      width: 33.3%;
      height: 70px;
      line-height: 70px;
      text-align: center;
      border-bottom: 1px solid #181616;
    }
  }
}
</style>